//package com.world.rickcloudendpoint.config;
//
//import org.springframework.beans.factory.DisposableBean;
//import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
//
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.TimeUnit;
//
///**
// * @description: 线程池的回收策略
// * @author: jlsong
// * @date: 2022/05/29 09:40:31
// * @version: 1.0
// */
//
//public abstract class ExecutorConfig extends CustomizableThreadFactory implements DisposableBean {
//
//    @Override
//    public void destroy() throws Exception {
//        shutdown();
//    }
//
//    /**
//     * Perform a shutdown on the underlying ExecutorService.
//     *
//     * @see ExecutorService#shutdown()
//     * @see ExecutorService#shutdownNow()
//     * @see #awaitTerminationIfNecessary()
//     */
//    public void shutdown() {
//        if (this.waitForTasksToCompleteOnShutdown){
//            this.executor.shutdown();
//        }else {
//            this.executor.shutdownNow();
//        }
//        awaitTerminationIfNecessary();
//    }
//
//    private void awaitTerminationIfNecessary() {
//        if (this.seconds > 0) {
//            try {
//                this.executor.awaitTerminatioon(this.seconds, TimeUnit.SECONDS);
//            } catch (InterruptedException e) {
//            }
//            Thread.currentThread().interrupt();
//        }
//    }
//}
